package com.zl.easybuy.service.impl;

import com.zl.easybuy.mapper.UserAddressMapper;
import com.zl.easybuy.pojo.User;
import com.zl.easybuy.pojo.UserAddress;
import com.zl.easybuy.service.UserAddressService;
import com.zl.easybuy.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserAddressServiceImpl implements UserAddressService {
    @Autowired
    UserAddressMapper userAddressMapper;
    @Override
    public List<UserAddress> findAddress() {
        User user= SessionUtil.getCurrentUser();
        List<UserAddress> userAddressList=userAddressMapper.findAddressByUserId(user.getId());
        return userAddressList;
    }

    @Override
    public UserAddress findAddressById(String addressId) {
        return userAddressMapper.findAddressById(Integer.valueOf(addressId));
    }

    @Override
    public int addAddress(String newAddress, String newRemark) {
        return 0;
    }
}
